curl --request POST \
--url https://api.topsort.com/toptimize/v1/rank \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"ranking": [
{
"type": "listings",
"slots": 3,
"pageSize": 3,
"page": {
"type": "category",
"value": "sneakers",
"pageId": "/category/sneakers"
},
"opaqueUserId": "u_9ske45",
"category": {
"ids": [
"sneakers",
"shoes"
]
},
"products": {
"ids": [
"p_PJbnN",
"p_ojng4"
]
}
}
]
}
'import requests
url = "https://api.topsort.com/toptimize/v1/rank"
payload = { "ranking": [
{
"type": "listings",
"slots": 3,
"pageSize": 3,
"page": {
"type": "category",
"value": "sneakers",
"pageId": "/category/sneakers"
},
"opaqueUserId": "u_9ske45",
"category": { "ids": ["sneakers", "shoes"] },
"products": { "ids": ["p_PJbnN", "p_ojng4"] }
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
ranking: [
{
type: 'listings',
slots: 3,
pageSize: 3,
page: {type: 'category', value: 'sneakers', pageId: '/category/sneakers'},
opaqueUserId: 'u_9ske45',
category: {ids: ['sneakers', 'shoes']},
products: {ids: ['p_PJbnN', 'p_ojng4']}
}
]
})
};
fetch('https://api.topsort.com/toptimize/v1/rank', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.topsort.com/toptimize/v1/rank",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ranking' => [
[
'type' => 'listings',
'slots' => 3,
'pageSize' => 3,
'page' => [
'type' => 'category',
'value' => 'sneakers',
'pageId' => '/category/sneakers'
],
'opaqueUserId' => 'u_9ske45',
'category' => [
'ids' => [
'sneakers',
'shoes'
]
],
'products' => [
'ids' => [
'p_PJbnN',
'p_ojng4'
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.topsort.com/toptimize/v1/rank"
payload := strings.NewReader("{\n \"ranking\": [\n {\n \"type\": \"listings\",\n \"slots\": 3,\n \"pageSize\": 3,\n \"page\": {\n \"type\": \"category\",\n \"value\": \"sneakers\",\n \"pageId\": \"/category/sneakers\"\n },\n \"opaqueUserId\": \"u_9ske45\",\n \"category\": {\n \"ids\": [\n \"sneakers\",\n \"shoes\"\n ]\n },\n \"products\": {\n \"ids\": [\n \"p_PJbnN\",\n \"p_ojng4\"\n ]\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.topsort.com/toptimize/v1/rank")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"ranking\": [\n {\n \"type\": \"listings\",\n \"slots\": 3,\n \"pageSize\": 3,\n \"page\": {\n \"type\": \"category\",\n \"value\": \"sneakers\",\n \"pageId\": \"/category/sneakers\"\n },\n \"opaqueUserId\": \"u_9ske45\",\n \"category\": {\n \"ids\": [\n \"sneakers\",\n \"shoes\"\n ]\n },\n \"products\": {\n \"ids\": [\n \"p_PJbnN\",\n \"p_ojng4\"\n ]\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.topsort.com/toptimize/v1/rank")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ranking\": [\n {\n \"type\": \"listings\",\n \"slots\": 3,\n \"pageSize\": 3,\n \"page\": {\n \"type\": \"category\",\n \"value\": \"sneakers\",\n \"pageId\": \"/category/sneakers\"\n },\n \"opaqueUserId\": \"u_9ske45\",\n \"category\": {\n \"ids\": [\n \"sneakers\",\n \"shoes\"\n ]\n },\n \"products\": {\n \"ids\": [\n \"p_PJbnN\",\n \"p_ojng4\"\n ]\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"results": [
{
"resultType": "listings",
"results": [
{
"rank": 1,
"type": "organic",
"id": "p_Mfk11",
"resolvedItemId": "WyJiX01mazExIiwiMTJhNTU4MjgtOGVhZC00Mjk5LTMyNjYtY2ViYjAwMmEwZmE4IiwibGlzdGluZ3MiLCJkZWZhdWx0IiwiIl0=="
},
{
"rank": 2,
"type": "sponsored",
"id": "p_Mfk15",
"resolvedItemId": "WyJiX01mazE1IiwiMTJhNTU4MjgtOGVhZC00Mjk5LTgzMjctY2ViYjAwMmEwZmE4IiwibGlzdGluZ3MiLCJkZWZhdWx0IiwiIl0="
},
{
"rank": 3,
"type": "organic",
"id": "p_PJbnN",
"resolvedItemId": "WyJlX1BKYm5OIiwiMTJhNTU4MjgtOGVhZC00Mjk5LTgzMjctY2ViYjAwMmEwZmE4IiwibGlzdGluZ3MiLCJkZWZhdWx0IiwiIl0="
}
],
"error": false
}
]
}{
"docUrl": "<string>",
"message": "<string>"
}[Beta] Rank objects
⚠️ Beta Access Required
Contact your sales representative to gain access to this endpoint and start using it.
Use the /ranking endpoint to re-rank objects to show on a page. This endpoint can retrieve sponsored
and non-sonsored objects and rank them together, according to an appropriate context and behavior information.
curl --request POST \
--url https://api.topsort.com/toptimize/v1/rank \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"ranking": [
{
"type": "listings",
"slots": 3,
"pageSize": 3,
"page": {
"type": "category",
"value": "sneakers",
"pageId": "/category/sneakers"
},
"opaqueUserId": "u_9ske45",
"category": {
"ids": [
"sneakers",
"shoes"
]
},
"products": {
"ids": [
"p_PJbnN",
"p_ojng4"
]
}
}
]
}
'import requests
url = "https://api.topsort.com/toptimize/v1/rank"
payload = { "ranking": [
{
"type": "listings",
"slots": 3,
"pageSize": 3,
"page": {
"type": "category",
"value": "sneakers",
"pageId": "/category/sneakers"
},
"opaqueUserId": "u_9ske45",
"category": { "ids": ["sneakers", "shoes"] },
"products": { "ids": ["p_PJbnN", "p_ojng4"] }
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
ranking: [
{
type: 'listings',
slots: 3,
pageSize: 3,
page: {type: 'category', value: 'sneakers', pageId: '/category/sneakers'},
opaqueUserId: 'u_9ske45',
category: {ids: ['sneakers', 'shoes']},
products: {ids: ['p_PJbnN', 'p_ojng4']}
}
]
})
};
fetch('https://api.topsort.com/toptimize/v1/rank', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.topsort.com/toptimize/v1/rank",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ranking' => [
[
'type' => 'listings',
'slots' => 3,
'pageSize' => 3,
'page' => [
'type' => 'category',
'value' => 'sneakers',
'pageId' => '/category/sneakers'
],
'opaqueUserId' => 'u_9ske45',
'category' => [
'ids' => [
'sneakers',
'shoes'
]
],
'products' => [
'ids' => [
'p_PJbnN',
'p_ojng4'
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.topsort.com/toptimize/v1/rank"
payload := strings.NewReader("{\n \"ranking\": [\n {\n \"type\": \"listings\",\n \"slots\": 3,\n \"pageSize\": 3,\n \"page\": {\n \"type\": \"category\",\n \"value\": \"sneakers\",\n \"pageId\": \"/category/sneakers\"\n },\n \"opaqueUserId\": \"u_9ske45\",\n \"category\": {\n \"ids\": [\n \"sneakers\",\n \"shoes\"\n ]\n },\n \"products\": {\n \"ids\": [\n \"p_PJbnN\",\n \"p_ojng4\"\n ]\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.topsort.com/toptimize/v1/rank")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"ranking\": [\n {\n \"type\": \"listings\",\n \"slots\": 3,\n \"pageSize\": 3,\n \"page\": {\n \"type\": \"category\",\n \"value\": \"sneakers\",\n \"pageId\": \"/category/sneakers\"\n },\n \"opaqueUserId\": \"u_9ske45\",\n \"category\": {\n \"ids\": [\n \"sneakers\",\n \"shoes\"\n ]\n },\n \"products\": {\n \"ids\": [\n \"p_PJbnN\",\n \"p_ojng4\"\n ]\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.topsort.com/toptimize/v1/rank")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ranking\": [\n {\n \"type\": \"listings\",\n \"slots\": 3,\n \"pageSize\": 3,\n \"page\": {\n \"type\": \"category\",\n \"value\": \"sneakers\",\n \"pageId\": \"/category/sneakers\"\n },\n \"opaqueUserId\": \"u_9ske45\",\n \"category\": {\n \"ids\": [\n \"sneakers\",\n \"shoes\"\n ]\n },\n \"products\": {\n \"ids\": [\n \"p_PJbnN\",\n \"p_ojng4\"\n ]\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"results": [
{
"resultType": "listings",
"results": [
{
"rank": 1,
"type": "organic",
"id": "p_Mfk11",
"resolvedItemId": "WyJiX01mazExIiwiMTJhNTU4MjgtOGVhZC00Mjk5LTMyNjYtY2ViYjAwMmEwZmE4IiwibGlzdGluZ3MiLCJkZWZhdWx0IiwiIl0=="
},
{
"rank": 2,
"type": "sponsored",
"id": "p_Mfk15",
"resolvedItemId": "WyJiX01mazE1IiwiMTJhNTU4MjgtOGVhZC00Mjk5LTgzMjctY2ViYjAwMmEwZmE4IiwibGlzdGluZ3MiLCJkZWZhdWx0IiwiIl0="
},
{
"rank": 3,
"type": "organic",
"id": "p_PJbnN",
"resolvedItemId": "WyJlX1BKYm5OIiwiMTJhNTU4MjgtOGVhZC00Mjk5LTgzMjctY2ViYjAwMmEwZmE4IiwibGlzdGluZ3MiLCJkZWZhdWx0IiwiIl0="
}
],
"error": false
}
]
}{
"docUrl": "<string>",
"message": "<string>"
}Autorisations
A valid API key generated in Topsort's UI. Use a TSE API key for calls to Auctions or Events API.
Corps
The context information to get the ranking, to rank organic and sponsored products.
1 - 5 elementsShow child attributes
Show child attributes
[
{
"type": "listings",
"slots": 3,
"pageSize": 3,
"page": {
"type": "category",
"value": "sneakers",
"pageId": "/category/sneakers"
},
"opaqueUserId": "u_9ske45"
}
]
Réponse
The ranking results. The list of winners will contain at most slots entries per auction. It may contain fewer or no entries at all if there aren't enough products to fill the slots.
1 - 5 elementsShow child attributes
Show child attributes
[
{
"resultType": "listings",
"results": [],
"error": false
}
]
Cette page vous a-t-elle été utile ?